package alterlabviz;

import java.sql.*;
import java.util.ArrayList;

import controlP5.Bang;
import controlP5.ControlCanvas;
import controlP5.ControlGroup;
import controlP5.ControlP5;
import controlP5.ScrollList;
import processing.core.PApplet;
import processing.core.PFont;


public class Main extends PApplet {
	//static parameters
	public final static int WIDTH = 400;
	public final static int HEIGHT = 800;	
	public final static int FRAME_RATE = 30;
	
	//public variables to access Processing and ControlP5 libraries
	public static ControlP5 controlP5;
	public PApplet theApplet = this;
	public CSVConn myconn;
	
	// currently used for the example data-loading below
	public ArrayList<ArrayList<Float>> myList;
	
	public VizElement ve;
	
	//sets up window and p5 start parameters
	public void setup() {
		size(WIDTH,HEIGHT);
		smooth();
		frameRate(FRAME_RATE);
		
		controlP5 = new ControlP5(this);
		
		ve = new VizElement(controlP5, "yeahman",0,0,100,100);
		
		controlP5.addToggle("toggle",false,100,160,20,20);

		controlP5.register(ve);
	}
	
	//draws objects at each iteration of the buffer
	//should not need to use at this level
	public void draw() {
		 background(0);	
	}


	
	//Initialize data
	void initializeData() {
		myconn = new CSVConn("../Data/");	
		
		// just load everything
		myList = new ArrayList< ArrayList<Float> >();
		myList.ensureCapacity(4329);
		
		if(myconn.query("SELECT * FROM partial_genes4329") == 1) {
			ResultSet results = myconn.getResults();
			try
			{
				int row = 0;
				results.next();
				while (results.next())
				{	
					myList.add( new  ArrayList<Float> () );				
					for(int col = 1; col < 13; col+=1) 
					{	
						(myList.get(row)).add(col-1, results.getFloat(col+1));
					}
					row+=1;
				}
			}
			catch(Exception e)
			{
				System.out.println("Oops-> " + e);
			}
		}
		
	}

}
